<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
<link rel="stylesheet" type="text/css" href="<%=request.getContextPath()%>/resources/css/easyui/themes/easyui.css">
<link rel="stylesheet" type="text/css" href="<%=request.getContextPath()%>/resources/css/admin/my-easyui.css">
<script type="text/javascript"	src="<%=request.getContextPath()%>/resources/js/jquery-1.7.2.min.js"></script>
<script type="text/javascript" src="<%=request.getContextPath()%>/resources/js/easyui/jquery.easyui.min.js"></script>
<script type="text/javascript" src="<%=request.getContextPath()%>/resources/js/easyui/easyui-lang-zh_CN.js"></script>
<script type="text/javascript">
	var ctx = "<%=request.getContextPath()%>";
	function mgr(value,row,index) {
		var node = "<input type='button' class='button' value='修改栏目'/>";
		node += "<input type='button' class='button' value='清空栏目'/>";
		return node;
	}
	function search() {
		$("#list").datagrid("reload");
	}
</script>
<script type="text/javascript">
	$(function() {
		$("#list").datagrid({
		    onBeforeLoad: function(param) {
		       param.name = $("#name").val();
		    }
		});
		$("#search").click(function() {
			search();
		});
		$("#add").click(function() {
			window.showModalDialog(ctx+"/admin/group/add",window,"dialogWidth:500px;dialogHeight:200px;status:no;help:yes;resizable:no;scroll:no;maximize:no;minimize;");
			search() ;
		});
		$("#edit").click(function() {
			var obj = $("#list").datagrid("getSelected");
			if(obj == null) alert("请选中要修改的分组");
			else {
				var url = ctx+"/admin/group/update/"+obj.id;
				window.showModalDialog(url,window,"dialogWidth:500px;dialogHeight:200px;status:no;help:yes;resizable:no;scroll:no;maximize:no;minimize;");
			}
			search() ;
		});
		$("#delete").click(function() {
			var obj = $("#list").datagrid("getSelected");
			if(obj == null) alert("请选中要删除的分组");
			else {
				if(confirm("是否确认删除")) {
					var url = ctx+"/admin/group/delete/"+obj.id;
					$.post(url,function(data) {
						if(data.success) search();
						alert(data.msg);
					});
				}
			}
		});
	});
</script>
</head>
<body>
	<div id="container">
		<table id="list" class="easyui-datagrid" style="height:450px;" title="用户组管理"
	           data-options="
		        url:'<%=request.getContextPath()%>/admin/group/list',
		        singleSelect:true,
		        fitColumns:true,
		        pagination:true,
		        rownumbers:true,
		        toolbar:'#toolbar',
		        pageList:[10,20]
	        ">
	        <thead>
	        <tr>
	            <th data-options="field:'ck',checkbox:true"></th>
	            <th data-options="field:'id',hidden:true">ID</th>
	            <th data-options="field:'name',width:200,align:'left'">组名称</th>
	            <th data-options="field:'mgr',formatter:mgr,width:150,align:'center'">管理栏目</th>
	        </tr>
	        </thead>
	    </table>
	    <div id="toolbar" style="padding:4px">
           	<span>组名称:</span><input type="text" style="width:140px" name="name" id="name">
            <input type="button" id="search" iconCls="icon-search" value="搜 索"/>
            <span style="margin-left:20px;">
   	    		<a class="easyui-linkbutton" id="add" data-options="iconCls:'icon-add',plain:true">添加</a>
   	    		<a class="easyui-linkbutton" id="edit" data-options="iconCls:'icon-edit',plain:true">修改</a>
   	    		<a class="easyui-linkbutton" id="delete" data-options="iconCls:'icon-remove',plain:true">删除</a>
   	    	</span>
        </div>
	</div>
</body>
</html>